Skip to content

Tweak open connection limits for unstaked connections#6953

Open
lijunwangs wants to merge 8 commits intoanza-xyz:masterfrom
lijunwangs:adjust_connection_count
Open

Tweak open connection limits for unstaked connections#6953
lijunwangs wants to merge 8 commits intoanza-xyz:masterfrom
lijunwangs:adjust_connection_count

Conversation

@lijunwangs
Copy link

@lijunwangs lijunwangs commented Jul 14, 2025

Problem

There are only 500 unstaked connection while we allow per address 8 concurrent connections. This leads to large number of connections from unstaked clients to contend for 500/8 for about 62 slots and cause churning.s

Summary of Changes

Reduce the per-connection from unstaked clients to 4 per ip address
Increase total connection count for unstaked connections to 2000.
Classifying eviction metrics between staked vs non-staked.

Fixes #

@lijunwangs lijunwangs force-pushed the adjust_connection_count branch from ae31e3e to c427776 Compare July 21, 2025 06:09
@lijunwangs lijunwangs marked this pull request as draft September 10, 2025 18:36
@lijunwangs lijunwangs force-pushed the adjust_connection_count branch 2 times, most recently from 1836c15 to 9aaaea4 Compare September 14, 2025 01:53
@codecov-commenter
Copy link

codecov-commenter commented Sep 14, 2025

Codecov Report

❌ Patch coverage is 87.09677% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.0%. Comparing base (7015e9c) to head (6c35787).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #6953   +/-   ##
=======================================
  Coverage    83.0%    83.0%           
=======================================
  Files         827      827           
  Lines      362695   362694    -1     
=======================================
+ Hits       301233   301249   +16     
+ Misses      61462    61445   -17     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@lijunwangs
Copy link
Author

Memory usage: observed using the bench-vote tools.

Connections:
32: 54.828 (MB)

500: 241.844 (MB)

2000: 645.684 (MB)

@lijunwangs lijunwangs marked this pull request as ready for review September 23, 2025 05:33
@lijunwangs lijunwangs force-pushed the adjust_connection_count branch from aae6915 to 285de8b Compare September 23, 2025 05:38
@lijunwangs lijunwangs force-pushed the adjust_connection_count branch from 285de8b to 345e3af Compare September 23, 2025 08:30
@alexpyattaev
Copy link

Memory usage: observed using the bench-vote tools.

Connections: 32: 54.828 (MB)

500: 241.844 (MB)

2000: 645.684 (MB)

This is for how much RX window and max streams per connection?

Copy link

@alexpyattaev alexpyattaev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall the direction is good, but I think this needs to get narrowed down to only address the unstaked connection limit, rather than everything at once. Especially we must avoid changes to SWQOS quotas.

};

const MAX_UNSTAKED_STREAMS_PERCENT: u64 = 20;
const MAX_UNSTAKED_STREAMS_PERCENT: u64 = 50;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We really should not be changing this here. This is completely unrelated change and will not have the impact you intend.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are using the connection count to distribute the streams/s to different connections out of the total streams/s allowed. With increased connection count quadrupled, the per connection TPS for unstaked, can be reduced to 1/4. The increased percentage reduces that effect.

Our allocation of staked vs. unstaked does not reflect the real usage in MB:

Screenshot 2025-09-23 at 11 25 40 AM

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it does, but it also cuts massively into the staked TPU bandwidth allocations, reducing them. Not sure that is desirable.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screenshot 2025-09-23 at 6 32 55 PM

The staked is not using the allocated bandwidth. See the max. Even 50% --> 250K/s should be more than enough for them to use realistically.

pub const DEFAULT_MAX_UNSTAKED_CONNECTIONS: usize = 2000;

/// The maximum number of connections that can be opened for unstaked peers.
pub const DEFAULT_MAX_UNSTAKED_CONNECTIONS_PER_IPADDR: usize = 4;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this change be in a separate PR?

@t-nelson
Copy link

this seems to be making several changes that are unrelated, but on the path to a singular goal. please split this up to isolate them

@lijunwangs lijunwangs force-pushed the adjust_connection_count branch from 471845d to 6c35787 Compare September 24, 2025 17:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants